<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
	<title>首页</title>
	<link rel="stylesheet" type="text/css" href="../css/hui.css" />
	<link rel="stylesheet" href="https://img.xyxsc.com/front/kuaishu/css/common.css">
	<link rel="stylesheet" href="https://img.xyxsc.com/front/kuaishu/css/nan.css">
	<link rel="stylesheet" href="https://img.xyxsc.com/front/kuaishu/css/mulu.css">
	<link rel="stylesheet" href="https://img.xyxsc.com/front/kuaishu/css/xiangqing.css">
	<link rel="stylesheet" href="https://img.xyxsc.com/front/kuaishu/css/book.css">
	<link rel="stylesheet" href="https://img.xyxsc.com/front/kuaishu/css/pinglun.css">
  	<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
  	<meta name="format-detection" content="telephone=no" />
  	<style>
  		span{
  			color: #666666;
  		}
  		h3{
  			color: #666666;
  		}
  		p{
  			color: #666666;
  		}
  		.nan-color{
  			color: #666666;
  		}
  		.pl-text{
  			color: #666666;
  		}
  		.pl-time{
  			color: #666666;
  		}
  	</style>
</head>
<body style="background-color:#fff;">
	<!-- 导航开始 -->
	<div class="banner01 nav-b">
    <ul>
        <li><a href="../main.html"  >首页</a></li>
        <li><a href="paihang.html" >排行</a></li>
        <li><a href="wanben.html" >完本</a></li>
        <li><a href="shuku.html" >书库</a></li>
        <li><a href="/user/bookshelf" >书架</a></li>
    </ul>
</div> 
	<!-- 导航结束 -->

	<div class="back-top fixed-top nan-tb">
	    <span id="book_name"></span>
	    <a class="back" href="../main.html"></a>
	</div>
	<div class="book-xq container">
		<div class="xq-left">
			<img id="face_img" src="" alt="">
		</div>
		<div class="xq-right">
			<h3 id="book_names">一品保镖</h3>				
			<p id="author"></p>
			<p id="fonts"></p>
			<p id="zj"></p>
			<p id="gx"></p>		
		</div>
	</div>
	<div class="book-btn container">
		<a onclick="yd();" class="nan-bg xq-look">免费阅读</a>
		<a onclick="ml();" class="xq-mulu">查看目录</a>
	</div>
	<div class="xq-main container line-b">
		<ul>
			<li>
				<h4 id="sc"></h4>
				<a onclick="handle(0);" id="btn_fav" class="sc">
					收藏
				</a>
			</li>
			<li>
				<h4 id="ds"></h4>
				<a onclick="handle(1);"  id="btn_fav">
					打赏
				</a>
			</li>
			<li>
				<h4 id="pl"></h4>
				<a onclick="handle(2);" >
					评论
				</a>
			</li>
		</ul>
	</div>
	<div class="clear"></div>
	<div class="book-jianjie container line-b">
		<div class="jianjie-title">
			<h3>书籍简介</h3>
		</div>
		<p><span class="" id="jianjie-txt"></span> <a class="more-a" onclick="hideorshow();" id="more">更多 <img id="moreImg" src='https://img.xyxsc.com/front/kuaishu/images/icon-more.png'></a></p>	
		<input id="jj" type="hidden">
	</div>
	<div class="mulu-list container">
		<h3>目录</h3>
		<a onclick="lastSection();">
			<div class="new_mulu line-b">
				<p>
					<span class="nan-color" style="color: #4696e6;">最新章节</span> 
					<b id="last_time"></b>
				</p>
				<p id="last_name"></p>
				<div class="txt" id="last_text"></div>
			</div>
		</a>
		<ul class="no-border">
			
		</ul>
	</div>
	<div class="pub-btn mt-10 pb-0"><a href="mulu.html" class="nan-bg xq-abtn ">查看更多目录</a></div>
	<div class="xq_pinglun container line-b">
		<p class="left">
			<span>评论</span>
			<i id="cnt"></i>
		</p>
		<p class="right"><a class="nan-color" onclick="otherPl();" style="color:#4696e6;">写评论</a></p>
	</div>
	<div id="plList">
	</div>
	<div class="pub-btn mt-20">
		<a onclick="otherPl();" class="nan-bg xq-abtn">显示更多评论</a>
	</div>
	<!-- 客服信息开始 -->
	<div class="nav-bottom bottom-bg">
		<ul>
	    	<li><a href="/main.html">首页</a></li>
	    	<li><a href="paihang.html">排行榜</a></li>
	    	<li><a href="wanben.html">完本</a></li>
	    	<li><a href="shuku.html">书库</a></li>
	    	<li><a href="/user/bookshelf">书架</a></li>
		</ul>
	</div>
	<div style="margin-top:22px;">
		<ul>
			<li>
				<a href="tel://18370940755">
		    		<div class="hui-list-text">在线联系电话：18370940755</div>
		    	</a>
			</li>
			<li>
				<a href="jjavascript:void(0);">
		    		<div class="hui-list-text">在线客服QQ：275300091</div>
		    	</a>
			</li>
			<li>
				<a href="javascript:void(0);">
		    		<div class="hui-list-text">问题反馈邮箱：275300091@qq.com</div>
		    	</a>
			</li>
		</ul>
	</div>
	<div style="background:#FFFFFF; margin-top:28px;">
	    <span type="button" class="hui-button hui-button-large" >
	    	鄂ICP备16023444号
	   	</span>
	</div>	<!-- 客服信息结束 -->
	<input type="hidden" id="sb">
	<input type="hidden" id="last" />
<script type="text/javascript" src="../js/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript" src="../js/hui.js" charset="UTF-8"></script>
<script type="text/javascript" src="https://img.xyxsc.com/front/kuaishu/wapjs/common.js"></script>
<script>
	var bookId = localStorage.getItem("bookid");
	var id = localStorage.getItem("id");
	//点击量加1
	hui.getJSON(
	    rootpath+'/books/addBooks/'+bookId,
	    function(msg){
	    },
	    function(e){
	        hui.iconToast('读取消息失败', 'warn');
	        console.log(e);
	    }
	);
	//判断改用户是否收藏过图书
	hui.postJSON(
		rootpath+"/booksCollect/findCollect",
		{
			booksId:bookId,
			userId:id
		},
		function(msg){
	        if(msg.result=="success"){
	        	$("#btn_fav").html("已收藏");
	        }
	    },
	    function(e){
	        hui.iconToast('读取消息失败', 'warn');
	    }
	);
	var html = '<div class="pinglun-list container">';
		html = html + '<div class="pl-text"><span class="nan-color" style="color:#4696e6">~</span>~</div>';
		html = html + '<div class="pl-footer">';
		html = html + '<div class="pl-time"><i></i>~</div>';
		html = html + '</div>';
		html = html + '</div>';
	hui.getJSON(
	    rootpath+'/books/findBooks/'+bookId,
	    function(msg){
	    	$("#book_name").html(msg.name+"-书籍详情");
	    	$("#book_names").html(msg.name);
	    	document.getElementById("face_img").src=rootpath+msg.faceImg;
	    	$("#author").html("作者："+msg.author);
	    	$("#fonts").html("字数："+parseFloat(msg.wordCount/10000)+"万字");
	    	$("#zj").html("章节数："+msg.section+"章节");
	    	$("#gx").html("更新时间："+getDate(msg.updateTime));
	    	$("#sc").html(msg.collectCount+"人");
	    	$("#pl").html(msg.discussCount+"人");
	    	$("#ds").html(msg.rewardCount+"人");
	    	var dd=msg.introduction.replace(/<\/?.+?>/g,"");
			var dds=dd.replace(/ /g,"");//dds为得到后的内容
			var ins = dds.substring(0,30)+"...";
	    	$("#jianjie-txt").html(ins);
	    	$("#jj").val(dds);
	    },
	    function(e){
	        hui.iconToast('读取消息失败', 'warn');
	        console.log(e);
	    }
	);
	hui.postJSON(
	    rootpath+'/booksDiscuss/booksDiscussList',
	    {
	    	pageSize:10,
	    	pageIndex:1,
	    	id:bookId
	    },
	    function(msg){
			console.log(msg);
			$("#cnt").html("（"+msg.total+"条）");
			var info = "";
			for(var i=0;i<msg.rows.length;i++){
				info = info + html.replace("~",msg.rows[i].userVo.name).replace("~","说："+msg.rows[i].content).replace("~",getDate(msg.rows[i].publishTime));
			}
			$("#plList").html(info);
	    },
	    function(e){
	        hui.iconToast('读取消息失败', 'warn');
	        console.log(e);
	    }
	);
	function yd(){
		hui.getJSON(
		    rootpath+'/booksSection/getMaxAndMinVo/'+bookId,
		    function(msg){
		    	if(msg.minId==0){
		    		hui.toast('暂无目录,无法阅读', 1000);
		    		return  false;
		    	}else{
		    		localStorage.removeItem("section_id");
					localStorage.setItem("section_id",msg.minId);
					location.href="sectionInfo.html";
		    	}
		    },
		    function(e){
		        hui.iconToast('读取消息失败', 'warn');
		        console.log(e);
		    }
		);
	}
	function ml(){
		location.href="mulu.html";
	}
	function hideorshow(){
		var val = $("#more").text();
		if(val.indexOf("更多")>-1){
			$("#jianjie-txt").html($("#jj").val());
			$("#more").html('隐藏 <img id="moreImg" src="https://img.xyxsc.com/front/kuaishu/images/icon-more01.png">');
		}else{
			var html = $("#jianjie-txt").html();
			$("#jianjie-txt").html(html.substr(0,30)+"...");
			$("#more").html('更多 <img id="moreImg" src="https://img.xyxsc.com/front/kuaishu/images/icon-more.png">');
		}
	}
	hui.getJSON(
	    rootpath+'/booksSection/getList/'+bookId,
	    function(msg){
	    	console.log(msg);
	    	if(msg=="[]"){
	    		alert("asdfsaf");
	    	}
	    		
	    	var dd=msg[0].content.replace(/<\/?.+?>/g,"");
			var dds=dd.replace(/ /g,"");//dds为得到后的内容
			var ins = dds.substring(0,30)+"...";
	    	$("#last_time").html("更新时间："+getDate(msg[0].publishTime)+"更新");
	    	$("#last_name").html(msg[0].name+"&nbsp;&nbsp;"+msg[0].title);
	    	$("#last_text").html(ins);
	    	$("#last").val(msg[0].id);
	    	$("#sb").val(msg[0].bookMoney);
	    	var hts = '<a onclick="sectionInfo(~);">';
			hts = hts + '<li>';
			hts = hts + '<span>~</span>';
			hts = hts + '<i >~</i>';
			hts = hts + '</li>';
			hts = hts + '</a>';
			var info = "";
	    	for(var i=1;i<msg.length;i++){
	    		info = info + hts.replace("~",msg[i].id).replace("~",msg[i].name+"&nbsp;&nbsp;"+msg[i].title).replace("~",msg[i].isMoney==0?"免费":"收费");
	    	}
	    	$(".no-border").html(info);
	    },
	    function(e){
	        hui.iconToast('读取消息失败', 'warn');
	        console.log(e);
	    }
	);
	function sectionInfo(id){
		localStorage.removeItem("section_id");
		localStorage.setItem("section_id",id);
		location.href="sectionInfo.html";
	}
	function otherPl(){
		localStorage.removeItem("bookName");
		localStorage.setItem("bookName",$("#book_names").html());
		location.href="pinglun.html";
	}
	var phone = localStorage.getItem("phone");
	function lastSection(){
		if(parseInt($("#sb").val())==0){
			localStorage.removeItem("section_id");
			localStorage.setItem("section_id",parseInt($("#last").val()));
			location.href="sectionInfo.html";
		}else{
//			if(!phone){
//				location.href="../login.html";
//			}else{
//				hui.toast("收费章节需要"+$("#sb").val()+"个书币", timer);
//			}
			hui.toast("收费章节需要"+$("#sb").val()+"个书币", 1000);
		}
	}
	function handle($id){
		var hand = new Array("收藏","打赏","评论");
		if(hand[$id].toString().indexOf("评论")>-1){
			otherPl();
		}else{
			var id = localStorage.getItem("id");
			if(!id){
				location.href="../login.html";
			}else{
				var html = $("#btn_fav").html();
				if(hand[$id].toString().indexOf("收藏")>-1){
					if(html.indexOf("已收藏")>-1){
						hui.toast('你已收藏该小说', 1000);
						return false;
					}else{
						hui.postJSON(
							rootpath+"/booksCollect/booksCollectAddSave",
							{
								booksId:bookId,
								userId:id
							},
							function(msg){
						        if(msg.result=="fail"){
						        	hui.toast('收藏失败', 1000);
						        }else{
						        	$("#btn_fav").html("已收藏");
						        	hui.toast('收藏成功', 1000);
						        }
						    },
						    function(e){
						        hui.iconToast('读取消息失败', 'warn');
						    }
						);
					}
				}
			}
		}
		
	}
</script>
</html>